package org.answer.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.answer.dao.BehaviorLogDao;
import org.answer.entity.PageResult;
import org.answer.entity.QueryPageBean;
import org.answer.pojo.BehaviorLog;
import org.answer.service.BehaviorLogService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BehaviorLogServiceImpl implements BehaviorLogService {

    @Autowired
    private BehaviorLogDao behaviorLogDao;

    @Override
    public void add(BehaviorLog behaviorLog) {
        behaviorLogDao.add(behaviorLog);
    }

    @Override
    public void delete(Integer id) {
        behaviorLogDao.delete(id);
    }

    @Override
    public PageResult pageQuery(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<BehaviorLog> page = behaviorLogDao.selectByCondition(queryPageBean.getQueryString());

        return new PageResult(page.getTotal(),page.getResult());
    }
}
